package com.powerbank.ordercenter.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powerbank.ordercenter.entity.OrderLog;
import com.powerbank.ordercenter.mapper.OrderLogMapper;
import com.powerbank.ordercenter.service.OrderLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 订单日志服务实现类
 */
@Service
@RequiredArgsConstructor
public class OrderLogServiceImpl extends ServiceImpl<OrderLogMapper, OrderLog> implements OrderLogService {

    private final OrderLogMapper orderLogMapper;

    @Override
    public void createLog(Long orderId, String orderNo, String operationType, 
                         String beforeStatus, String afterStatus, 
                         Long operatorId, String operatorType, String operationDesc) {
        OrderLog log = new OrderLog();
        log.setOrderId(orderId);
        log.setOrderNo(orderNo);
        log.setOperationType(operationType);
        log.setBeforeStatus(beforeStatus);
        log.setAfterStatus(afterStatus);
        log.setOperatorId(operatorId);
        log.setOperatorType(operatorType);
        log.setOperationDesc(operationDesc);
        
        save(log);
    }

    @Override
    public List<OrderLog> getLogsByOrderId(Long orderId) {
        return orderLogMapper.findByOrderId(orderId);
    }

    @Override
    public List<OrderLog> getLogsByOrderNo(String orderNo) {
        return orderLogMapper.findByOrderNo(orderNo);
    }
}